package com.juxing.sdk.concurrent;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池
 * @author brochen
 * @main mongibello@163.com
 */
public class ThreadPool {
	private ThreadPoolExecutor executor = null;
	
	public ThreadPool() {
		this(10, 20);
	}
	public ThreadPool(int corePoolSize, int maxPoolSize) {
		executor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, 0L,
				TimeUnit.MICROSECONDS, new ArrayBlockingQueue<Runnable>(
						100000), new ThreadPoolExecutor.DiscardPolicy());
	}
	
	/**
	 * 执行
	 * @param r
	 */
	public void execute(Runnable r) {
		executor.execute(r);
	}
}
